package com.beyondbit.hr.core.controller;

import com.beyondbit.hr.api.dto.request.OrgUserQueryReq;
import com.beyondbit.hr.core.dao.OrgUserMapper;
import com.beyondbit.hr.core.entity.OrgUser;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/api/demo")
public class MybatisDemoController {

    @Autowired
    OrgUserMapper orgUserMapper;

    @RequestMapping(value ="/orgUsers", method = {RequestMethod.POST}, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Successful — 请求已完成"),
            @ApiResponse(code = 500, message = "服务端错误")
    })
    @ResponseBody
    public List<OrgUser> orgUsers(@RequestBody OrgUserQueryReq req) {
        return orgUserMapper.findOrgUser(req);
    }
}
